package com.his.his_system.controller.DruginventoryController;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.his.his_system.domain.DzmHisDoctor;
import com.his.his_system.domain.DzmHisHospital;
import com.his.his_system.domain.DzmHisPrescriptionExtracharges;
import com.his.his_system.service.DzmHisDoctorService;
import com.his.his_system.service.DzmHisHospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/api")
public class ClinicController {

    @Autowired
    private DzmHisHospitalService dzmHisHospitalService;

    @Autowired
    private DzmHisDoctorService dzmHisDoctorService;

    /**
     * 获取诊所信息
     * @return
     */
//        医院表
    @GetMapping("selectZhenSuoXX")
    public List<DzmHisHospital> selectZhenSuoXX(){
        return dzmHisHospitalService.list();
    }
//     医生表
    @GetMapping("selectDOctor")
    public List<DzmHisDoctor> selectDOctor(){
        return dzmHisDoctorService.list();
    }

    @GetMapping("updatayiyuanxx")
    public boolean updataYiyuanxx(DzmHisHospital dzmHisHospital){
        UpdateWrapper<DzmHisHospital> a=new UpdateWrapper();
        a.eq("id",1);
        a.set("owner_name",dzmHisHospital.getOwnerName());
        a.set("owner_post",dzmHisHospital.getOwnerPost());
        a.set("owner_mobile",dzmHisHospital.getOwnerMobile());
        a.set("hospital_name",dzmHisHospital.getHospitalName());
        a.set("address",dzmHisHospital.getAddress());
        return  dzmHisHospitalService.update(a);
    }
    /**
     * 编辑诊所信息
     */
    @GetMapping(value = "Clinicxiugai")
    public Object xiugai(DzmHisHospital dzmHisHospital){
        UpdateWrapper<DzmHisHospital>updateWrapper=new UpdateWrapper<>();
        updateWrapper.eq("id",1)
                .set("owner_name",dzmHisHospital.getOwnerName())
                .set("owner_post",dzmHisHospital.getOwnerPost())
                .set("owner_mobile",dzmHisHospital.getOwnerMobile())
                .set("major_field",dzmHisHospital.getMajorField())
                .set("hospital_name",dzmHisHospital.getHospitalName());
        return dzmHisHospitalService.update(updateWrapper);
    }
}


